const env = 'production';

const hosts = {
  development: '',
  production: 'https://as365.try0574.com/api/v1'
  //production: 'https://www.91ygp.com/api/v1'
}

const api = {
  lawyerSetup: {  //律师角色的接口
    certificationLawyer: { //律师认证 填写认证信息
      method: 'POST',
      url: '/member/lawyer'
    },
    lawyerDetail: { //律师详情
      method: 'GET',
      url: '/member/lawyer'
    },
    articleList: { //律师文章列表
      method: 'GET',
      url: '/member/lawyer-article'
    },
    articleDetail: { //律师文章详情
      method: 'GET',
      url: '/member/lawyer-article'
    },
    writeArticle: { //律师  发表文章
      method: 'POST',
      url: '/member/lawyer-article'
    },
    lawyerSpeciality: { //律师专长
      method: 'GET',
      url: '/member/lawyer-speciality'
    },
    lawOfficeList: { //律师函列表
      method: 'GET',
      url: '/contract/law-office'
    },
    lawOfficeDetail: { //律师函详情
      method: 'GET',
      url: '/contract/law-office'
    },
    memberInfo: { //律师 我的账户信息
      method: 'GET',
      url: '/member/member-info'
    },
    lawyerMoney: { //律师所得费用列表
      method: 'GET',
      url: '/member/lawyer-money'
    },
    getProvinces: { //获取省市区
      method: 'GET',
      url: '/base/provinces'
    },
    lawyerMoneyQuestions: { //律师获取费用（电话专问 ， 图文专问）
      method: 'POST',
      url: '/member/lawyer-money'
    },
    lawyerInfoAmend: { //律师信息修改
      method: 'POST',
      url: '/member/lawyer/payset'
    },
    serveinfo: { //服务详情
      method: 'POST',
      url: '/member/lawyer-money/serveinfo'
    },
    serveinfoComplete: { //服务详情点击完成
      method: 'PUT',
      url: '/member/lawyer-money'
    },
    serveinfoReply: { //服务详情 图文回复
      method: 'POST',
      url: '/member/lawyer-money/reply'
    },
    serveinfoLawyerScore: { //服务详情 对律师进行评价
      method: 'POST',
      url: '/member/lawyer-score'
    },
  }
}

module.exports = {
  env,
  api: disposeUrl(api, hosts[env])
}

function disposeUrl(obj, prefix) {
  Object.keys(obj).forEach(v => {
    if (obj[v].url) {
      obj[v].url = prefix + obj[v].url
    } else {
      obj[v] = disposeUrl(obj[v], prefix)
    }
  })
  return obj
}